package com.edward.weather.controller;

import com.edward.weather.model.WeatherData;
import com.edward.weather.service.WeatherService;
import com.edward.weather.vo.request.WeatherRequestVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/weather")
public class WeatherController {

    @Autowired
    private WeatherService weatherService;

    /**
     * 实时天气
     * @param location
     * @return
     */
    @GetMapping("/current")
    public WeatherData getCurrentWeather(@RequestParam(defaultValue = "101010100") String location) {
        return weatherService.getWeatherData(location);
    }

    /**
     * 天气预报几天
     * @param weatherRequestVO
     * @return
     */
    @GetMapping("/day")
    public WeatherData dayWeather(@RequestBody WeatherRequestVO weatherRequestVO) {
        return weatherService.dayWeather(weatherRequestVO);
    }


    /**
     * 天气指数
     * @param weatherRequestVO
     * @return
     */
    @GetMapping("/indices")
    public WeatherData indices(@RequestBody WeatherRequestVO weatherRequestVO) {
        return weatherService.indices(weatherRequestVO);
    }
} 